home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS19.ADF
/
C
/
SkinnyC
/
Listing3.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-01-27
|
3KB
|
112 lines
/******************************************************
* REQUEST - A simple boolean requester command for use
* within EXECUTE command files.
*******************************************************
* BVO Computing Services, January 1987, Bob Riemersma
*******************************************************
* Format: REQUEST <string>
* Template: REQUEST " "
* Purpose: To ask the user a yes/no question from
* within an EXECUTE command file.
* Specification:
* REQUEST invokes a system requester displaying the
* text argument given, and accepts either a "Yes" or
* a"No" response via the requester's boolean gadgets.
* This response is communicated to the command stream
* via REQUEST's return result: 0 = No, 5 = Yes.
* Example:
* REQUEST "Are you older than 35?"
* IF WARN ;WARN = Yes
* ECHO "Hmmm, so you are."
* ELSE
* ECHO "Just a young whippersnapper!"
* ENDIF
*******************************************************
* Note to rodent-haters:
* Beginning with KS/WB 1.2 you may respond using
* "Left Amiga-V" for "Yes", "Left Amiga-B" for "No".
******************************************************/
#include <exec/types.h>
#include <libraries/dosextens.h>
#include <intuition/intuition.h>
struct IntuitionBase *IntuitionBase;
#define INTUITION_REV 0
struct IntuiText Question =
{
2, 1, /* FrontPen, BackPen */
JAM1,
8, 6, /* LeftEdge, TopEdge */
NULL, /* Use default font */
NULL, /* IText, filled at runtime */
NULL /* No linked IntuiTexts */
},
Positive =
{
2, 1,
JAM1,
6, 4,
NULL,
"Yes",
NULL
},
Negative =
{
2, 1,
JAM1,
6, 4,
NULL,
"No",
NULL
};
#define Me 0
extern struct Process *FindTask();
struct Process *Myself;
extern BOOL AutoRequest();
_main(CommandLine)
UBYTE *CommandLine;
{
int QuestionChars,
ReqWidth;
BOOL Yes;
/* Scan CommandLine for first quote */
while (*CommandLine != '\0' && *CommandLine != '"')
CommandLine++;
if (*CommandLine == '\0')
_exit(120);
/* Skip quote & store ptr, scan to final quote (counting
* chars), '\0' it to terminate the IText string. */
Question.IText = ++CommandLine;
QuestionChars = 0;
while (*CommandLine != '\0' && *CommandLine != '"')
{
CommandLine++;
QuestionChars++;
}
if (*CommandLine == '\0')
_exit(120);
*CommandLine = '\0';
IntuitionBase = (struct IntuitionBase *)
OpenLibrary("intuition.library", INTUITION_REV);
if (IntuitionBase == NULL)
_exit(FALSE);
Myself = FindTask(Me);
if ((ReqWidth = 8*QuestionChars+40) < 200)
ReqWidth = 200;
Yes = AutoRequest(Myself->pr_WindowPtr, /* Console Window */
&Question, &Positive, &Negative, /* IntuiTexts */
NULL, NULL, /* No extern. events */
ReqWidth, 50); /* Width, Height */
CloseLibrary(IntuitionBase);
_exit((Yes) ? 5 : 0);
}